// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.inventory;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Objects;
import java.util.function.Predicate;
import se.krka.kahlua.integration.LuaReturn;
import se.krka.kahlua.vm.LuaClosure;
import zombie.Lua.LuaManager;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.characters.SurvivorDesc;
import zombie.core.Core;
import zombie.core.Rand;
import zombie.core.network.ByteBufferWriter;
import zombie.core.raknet.UdpConnection;
import zombie.debug.DebugLog;
import zombie.inventory.types.AlarmClock;
import zombie.inventory.types.AlarmClockClothing;
import zombie.inventory.types.Clothing;
import zombie.inventory.types.Drainable;
import zombie.inventory.types.DrainableComboItem;
import zombie.inventory.types.Food;
import zombie.inventory.types.HandWeapon;
import zombie.inventory.types.InventoryContainer;
import zombie.inventory.types.Key;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoObject;
import zombie.iso.IsoWorld;
import zombie.iso.objects.IsoBarbecue;
import zombie.iso.objects.IsoCompost;
import zombie.iso.objects.IsoDeadBody;
import zombie.iso.objects.IsoFireplace;
import zombie.iso.objects.IsoMannequin;
import zombie.iso.objects.IsoStove;
import zombie.iso.objects.IsoWorldInventoryObject;
import zombie.network.GameClient;
import zombie.network.PacketTypes;
import zombie.popman.ObjectPool;
import zombie.scripting.ScriptManager;
import zombie.scripting.objects.Item;
import zombie.util.StringUtils;
import zombie.util.Type;
import zombie.vehicles.BaseVehicle;
import zombie.vehicles.VehiclePart;

public final class ItemContainer {
    private static final ArrayList<InventoryItem> tempList = new ArrayList();
    private static final ArrayList<IsoObject> s_tempObjects = new ArrayList();
    public boolean active = false;
    private boolean dirty = true;
    public boolean IsDevice = false;
    public float ageFactor = 1.0F;
    public float CookingFactor = 1.0F;
    public int Capacity = 50;
    public InventoryItem containingItem = null;
    public ArrayList<InventoryItem> Items = new ArrayList();
    public ArrayList<InventoryItem> IncludingObsoleteItems = new ArrayList();
    public IsoObject parent = null;
    public IsoGridSquare SourceGrid = null;
    public VehiclePart vehiclePart = null;
    public InventoryContainer inventoryContainer = null;
    public boolean bExplored = false;
    public String type = "none";
    public int ID = 0;
    private boolean drawDirty = true;
    private float customTemperature = 0.0F;
    private boolean hasBeenLooted = false;
    private String openSound = null;
    private String closeSound = null;
    private String putSound = null;
    private String OnlyAcceptCategory = null;
    private String AcceptItemFunction = null;
    private int weightReduction = 0;
    private String containerPosition = null;
    private String freezerPosition = null;
    private static final ThreadLocal<ItemContainer.Comparators> TL_comparators = ThreadLocal.withInitial(ItemContainer.Comparators::new);
    private static final ThreadLocal<ItemContainer.InventoryItemListPool> TL_itemListPool = ThreadLocal.withInitial(ItemContainer.InventoryItemListPool::new);
    private static final ThreadLocal<ItemContainer.Predicates> TL_predicates = ThreadLocal.withInitial(ItemContainer.Predicates::new);

    public ItemContainer(int _ID, String containerName, IsoGridSquare square, IsoObject _parent) {
        this.ID = _ID;
        this.parent = _parent;
        this.type = containerName;
        this.SourceGrid = square;
        if (containerName.equals("fridge")) {
            this.ageFactor = 0.02F;
            this.CookingFactor = 0.0F;
        }
    }

    public ItemContainer(String containerName, IsoGridSquare square, IsoObject _parent) {
        this.ID = -1;
        this.parent = _parent;
        this.type = containerName;
        this.SourceGrid = square;
        if (containerName.equals("fridge")) {
            this.ageFactor = 0.02F;
            this.CookingFactor = 0.0F;
        }
    }

    public ItemContainer(int _ID) {
        this.ID = _ID;
    }

    public ItemContainer() {
        this.ID = -1;
    }

    public static float floatingPointCorrection(float val) {
        byte _byte = 100;
        float _float = val * (float)_byte;
        return (float)((int)(_float - (float)((int)_float) >= 0.5F ? _float + 1.0F : _float)) / (float)_byte;
    }

    public int getCapacity() {
        return this.Capacity;
    }

    public void setCapacity(int _int) {
        this.Capacity = _int;
    }

    public InventoryItem FindAndReturnWaterItem(int uses) {
        for (int _int = 0; _int < this.getItems().size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(_int);
            if (inventoryItem instanceof DrainableComboItem && inventoryItem.isWaterSource()) {
                DrainableComboItem drainableComboItem = (DrainableComboItem)inventoryItem;
                if (drainableComboItem.getDrainableUsesInt() >= uses) {
                    return inventoryItem;
                }
            }
        }

        return null;
    }

    public InventoryItem getItemFromTypeRecurse(String _type) {
        return this.getFirstTypeRecurse(_type);
    }

    public int getEffectiveCapacity(IsoGameCharacter chr) {
        if (chr != null && !(this.parent instanceof IsoGameCharacter) && !(this.parent instanceof IsoDeadBody) && !"floor".equals(this.getType())) {
            if (chr.Traits.Organized.isSet()) {
                return (int)Math.max((float)this.Capacity * 1.3F, (float)(this.Capacity + 1));
            }

            if (chr.Traits.Disorganized.isSet()) {
                return (int)Math.max((float)this.Capacity * 0.7F, 1.0F);
            }
        }

        return this.Capacity;
    }

    public boolean hasRoomFor(IsoGameCharacter chr, InventoryItem item) {
        if (this.vehiclePart != null && this.vehiclePart.getId().contains("Seat") && this.Items.isEmpty() && item.getUnequippedWeight() <= 50.0F) {
            return true;
        } else if (floatingPointCorrection(this.getCapacityWeight()) + item.getUnequippedWeight() <= (float)this.getEffectiveCapacity(chr)) {
            return this.getContainingItem() != null
                    && this.getContainingItem().getEquipParent() != null
                    && this.getContainingItem().getEquipParent().getInventory() != null
                    && !this.getContainingItem().getEquipParent().getInventory().contains(item)
                ? floatingPointCorrection(this.getContainingItem().getEquipParent().getInventory().getCapacityWeight()) + item.getUnequippedWeight()
                    <= (float)this.getContainingItem().getEquipParent().getInventory().getEffectiveCapacity(chr)
                : true;
        } else {
            return false;
        }
    }

    public boolean hasRoomFor(IsoGameCharacter chr, float weightVal) {
        return floatingPointCorrection(this.getCapacityWeight()) + weightVal <= (float)this.getEffectiveCapacity(chr);
    }

    public boolean isItemAllowed(InventoryItem item) {
        if (item == null) {
            return false;
        } else {
            String string0 = this.getOnlyAcceptCategory();
            if (string0 != null && !string0.equalsIgnoreCase(item.getCategory())) {
                return false;
            } else {
                String string1 = this.getAcceptItemFunction();
                if (string1 != null) {
                    Object object = LuaManager.getFunctionObject(string1);
                    if (object != null) {
                        Boolean _booleanx = LuaManager.caller.protectedCallBoolean(LuaManager.thread, object, this, item);
                        if (_booleanx != Boolean.TRUE) {
                            return false;
                        }
                    }
                }

                if (this.parent != null && !this.parent.isItemAllowedInContainer(this, item)) {
                    return false;
                } else if (this.getType().equals("clothingrack") && !(item instanceof Clothing)) {
                    return false;
                } else if (this.getParent() != null
                    && this.getParent().getProperties() != null
                    && this.getParent().getProperties().Val("CustomName") != null
                    && this.getParent().getProperties().Val("CustomName").equals("Toaster")
                    && !item.hasTag("FitsToaster")) {
                    return false;
                } else {
                    if (this.getParent() != null && this.getParent().getProperties() != null && this.getParent().getProperties().Val("GroupName") != null) {
                        boolean _boolean = this.getParent().getProperties().Val("GroupName").equals("Coffee")
                            || this.getParent().getProperties().Val("GroupName").equals("Espresso");
                        if (_boolean && !item.hasTag("CoffeeMaker")) {
                            return false;
                        }
                    }

                    return true;
                }
            }
        }
    }

    public boolean isRemoveItemAllowed(InventoryItem item) {
        return item == null ? false : this.parent == null || this.parent.isRemoveItemAllowedFromContainer(this, item);
    }

    public boolean isExplored() {
        return this.bExplored;
    }

    public void setExplored(boolean b) {
        this.bExplored = b;
    }

    public boolean isInCharacterInventory(IsoGameCharacter chr) {
        if (chr.getInventory() == this) {
            return true;
        } else {
            if (this.containingItem != null) {
                if (chr.getInventory().contains(this.containingItem, true)) {
                    return true;
                }

                if (this.containingItem.getContainer() != null) {
                    return this.containingItem.getContainer().isInCharacterInventory(chr);
                }
            }

            return false;
        }
    }

    public boolean isInside(InventoryItem item) {
        if (this.containingItem == null) {
            return false;
        } else {
            return this.containingItem == item ? true : this.containingItem.getContainer() != null && this.containingItem.getContainer().isInside(item);
        }
    }

    public InventoryItem getContainingItem() {
        return this.containingItem;
    }

    public InventoryItem DoAddItem(InventoryItem item) {
        return this.AddItem(item);
    }

    public InventoryItem DoAddItemBlind(InventoryItem item) {
        return this.AddItem(item);
    }

    public ArrayList<InventoryItem> AddItems(String item, int use) {
        ArrayList arrayList = new ArrayList();

        for (int _int = 0; _int < use; _int++) {
            InventoryItem inventoryItem = this.AddItem(item);
            if (inventoryItem != null) {
                arrayList.add(inventoryItem);
            }
        }

        return arrayList;
    }

    public void AddItems(InventoryItem item, int use) {
        for (int _int = 0; _int < use; _int++) {
            this.AddItem(item.getFullType());
        }
    }

    public int getNumberOfItem(String findItem, boolean includeReplaceOnDeplete) {
        return this.getNumberOfItem(findItem, includeReplaceOnDeplete, false);
    }

    public int getNumberOfItem(String findItem) {
        return this.getNumberOfItem(findItem, false);
    }

    public int getNumberOfItem(String findItem, boolean includeReplaceOnDeplete, ArrayList<ItemContainer> containers) {
        int _int = this.getNumberOfItem(findItem, includeReplaceOnDeplete);
        if (containers != null) {
            for (ItemContainer itemContainer : containers) {
                if (itemContainer != this) {
                    _int += itemContainer.getNumberOfItem(findItem, includeReplaceOnDeplete);
                }
            }
        }

        return _int;
    }

    public int getNumberOfItem(String findItem, boolean includeReplaceOnDeplete, boolean insideInv) {
        int int0 = 0;

        for (int int1 = 0; int1 < this.Items.size(); int1++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(int1);
            if (inventoryItem.getFullType().equals(findItem) || inventoryItem.getType().equals(findItem)) {
                int0++;
            } else if (insideInv && inventoryItem instanceof InventoryContainer) {
                int0 += ((InventoryContainer)inventoryItem).getItemContainer().getNumberOfItem(findItem);
            } else if (includeReplaceOnDeplete
                && inventoryItem instanceof DrainableComboItem
                && ((DrainableComboItem)inventoryItem).getReplaceOnDeplete() != null) {
                DrainableComboItem drainableComboItem = (DrainableComboItem)inventoryItem;
                if (drainableComboItem.getReplaceOnDepleteFullType().equals(findItem) || drainableComboItem.getReplaceOnDeplete().equals(findItem)) {
                    int0++;
                }
            }
        }

        return int0;
    }

    public InventoryItem addItem(InventoryItem item) {
        return this.AddItem(item);
    }

    public InventoryItem AddItem(InventoryItem item) {
        if (item == null) {
            return null;
        } else if (this.containsID(item.id)) {
            System.out.println("Error, container already has id");
            return this.getItemWithID(item.id);
        } else {
            this.drawDirty = true;
            if (this.parent != null) {
                this.dirty = true;
            }

            if (this.parent != null && !(this.parent instanceof IsoGameCharacter)) {
                this.parent.DirtySlice();
            }

            if (item.container != null) {
                item.container.Remove(item);
            }

            item.container = this;
            this.Items.add(item);
            if (IsoWorld.instance.CurrentCell != null) {
                IsoWorld.instance.CurrentCell.addToProcessItems(item);
            }

            return item;
        }
    }

    public InventoryItem AddItemBlind(InventoryItem item) {
        if (item == null) {
            return null;
        } else if (item.getWeight() + this.getCapacityWeight() > (float)this.getCapacity()) {
            return null;
        } else {
            if (this.parent != null && !(this.parent instanceof IsoGameCharacter)) {
                this.parent.DirtySlice();
            }

            this.Items.add(item);
            return item;
        }
    }

    public InventoryItem AddItem(String _type) {
        this.drawDirty = true;
        if (this.parent != null && !(this.parent instanceof IsoGameCharacter)) {
            this.dirty = true;
        }

        Item item = ScriptManager.instance.FindItem(_type);
        if (item == null) {
            DebugLog.log("ERROR: ItemContainer.AddItem: can't find " + _type);
            return null;
        } else if (item.OBSOLETE) {
            return null;
        } else {
            InventoryItem inventoryItem = null;
            int int0 = item.getCount();

            for (int int1 = 0; int1 < int0; int1++) {
                inventoryItem = InventoryItemFactory.CreateItem(_type);
                if (inventoryItem == null) {
                    return null;
                }

                inventoryItem.container = this;
                this.Items.add(inventoryItem);
                if (inventoryItem instanceof Food) {
                    ((Food)inventoryItem).setHeat(this.getTemprature());
                }

                if (IsoWorld.instance.CurrentCell != null) {
                    IsoWorld.instance.CurrentCell.addToProcessItems(inventoryItem);
                }
            }

            return inventoryItem;
        }
    }

    public boolean AddItem(String _type, float useDelta) {
        this.drawDirty = true;
        if (this.parent != null && !(this.parent instanceof IsoGameCharacter)) {
            this.dirty = true;
        }

        InventoryItem inventoryItem = InventoryItemFactory.CreateItem(_type);
        if (inventoryItem == null) {
            return false;
        } else {
            if (inventoryItem instanceof Drainable) {
                ((Drainable)inventoryItem).setUsedDelta(useDelta);
            }

            inventoryItem.container = this;
            this.Items.add(inventoryItem);
            return true;
        }
    }

    public boolean contains(InventoryItem item) {
        return this.Items.contains(item);
    }

    public boolean containsWithModule(String moduleType) {
        return this.containsWithModule(moduleType, false);
    }

    public boolean containsWithModule(String moduleType, boolean withDeltaLeft) {
        String string0 = moduleType;
        String string1 = "Base";
        if (moduleType.contains(".")) {
            string1 = moduleType.split("\\.")[0];
            string0 = moduleType.split("\\.")[1];
        }

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem == null) {
                this.Items.remove(_int);
                _int--;
            } else if (inventoryItem.type.equals(string0.trim())
                && string1.equals(inventoryItem.getModule())
                && (!withDeltaLeft || !(inventoryItem instanceof DrainableComboItem) || !(((DrainableComboItem)inventoryItem).getUsedDelta() <= 0.0F))) {
                return true;
            }
        }

        return false;
    }

    public void removeItemOnServer(InventoryItem item) {
        if (GameClient.bClient) {
            if (this.containingItem != null && this.containingItem.getWorldItem() != null) {
                GameClient.instance.addToItemRemoveSendBuffer(this.containingItem.getWorldItem(), this, item);
            } else {
                GameClient.instance.addToItemRemoveSendBuffer(this.parent, this, item);
            }
        }
    }

    public void addItemOnServer(InventoryItem item) {
        if (GameClient.bClient) {
            if (this.containingItem != null && this.containingItem.getWorldItem() != null) {
                GameClient.instance.addToItemSendBuffer(this.containingItem.getWorldItem(), this, item);
            } else {
                GameClient.instance.addToItemSendBuffer(this.parent, this, item);
            }
        }
    }

    public boolean contains(InventoryItem itemToFind, boolean doInv) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();

        for (int int0 = 0; int0 < this.Items.size(); int0++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(int0);
            if (inventoryItem == null) {
                this.Items.remove(int0);
                int0--;
            } else {
                if (inventoryItem == itemToFind) {
                    ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                    return true;
                }

                if (doInv
                    && inventoryItem instanceof InventoryContainer
                    && ((InventoryContainer)inventoryItem).getInventory() != null
                    && !inventoryItemList.contains(inventoryItem)) {
                    inventoryItemList.add(inventoryItem);
                }
            }
        }

        for (int int1 = 0; int1 < inventoryItemList.size(); int1++) {
            ItemContainer itemContainer = ((InventoryContainer)inventoryItemList.get(int1)).getInventory();
            if (itemContainer.contains(itemToFind, doInv)) {
                ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                return true;
            }
        }

        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return false;
    }

    public boolean contains(String _type, boolean doInv) {
        return this.contains(_type, doInv, false);
    }

    public boolean containsType(String _type) {
        return this.contains(_type, false, false);
    }

    public boolean containsTypeRecurse(String _type) {
        return this.contains(_type, true, false);
    }

    private boolean testBroken(boolean _boolean, InventoryItem inventoryItem) {
        return !_boolean ? true : !inventoryItem.isBroken();
    }

    public boolean contains(String _type, boolean doInv, boolean ignoreBroken) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        if (_type.contains("Type:")) {
            for (int int0 = 0; int0 < this.Items.size(); int0++) {
                InventoryItem inventoryItem0 = (InventoryItem)this.Items.get(int0);
                if (_type.contains("Food") && inventoryItem0 instanceof Food) {
                    ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                    return true;
                }

                if (_type.contains("Weapon") && inventoryItem0 instanceof HandWeapon && this.testBroken(ignoreBroken, inventoryItem0)) {
                    ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                    return true;
                }

                if (_type.contains("AlarmClock") && inventoryItem0 instanceof AlarmClock) {
                    ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                    return true;
                }

                if (_type.contains("AlarmClockClothing") && inventoryItem0 instanceof AlarmClockClothing) {
                    ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                    return true;
                }

                if (doInv
                    && inventoryItem0 instanceof InventoryContainer
                    && ((InventoryContainer)inventoryItem0).getInventory() != null
                    && !inventoryItemList.contains(inventoryItem0)) {
                    inventoryItemList.add(inventoryItem0);
                }
            }
        } else if (_type.contains("/")) {
            String[] string0 = _type.split("/");

            for (String string1 : string0) {
                for (int int1 = 0; int1 < this.Items.size(); int1++) {
                    InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(int1);
                    if (compareType(string1.trim(), inventoryItem1) && this.testBroken(ignoreBroken, inventoryItem1)) {
                        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                        return true;
                    }

                    if (doInv
                        && inventoryItem1 instanceof InventoryContainer
                        && ((InventoryContainer)inventoryItem1).getInventory() != null
                        && !inventoryItemList.contains(inventoryItem1)) {
                        inventoryItemList.add(inventoryItem1);
                    }
                }
            }
        } else {
            for (int int2 = 0; int2 < this.Items.size(); int2++) {
                InventoryItem inventoryItem2 = (InventoryItem)this.Items.get(int2);
                if (inventoryItem2 == null) {
                    this.Items.remove(int2);
                    int2--;
                } else {
                    if (compareType(_type.trim(), inventoryItem2) && this.testBroken(ignoreBroken, inventoryItem2)) {
                        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                        return true;
                    }

                    if (doInv
                        && inventoryItem2 instanceof InventoryContainer
                        && ((InventoryContainer)inventoryItem2).getInventory() != null
                        && !inventoryItemList.contains(inventoryItem2)) {
                        inventoryItemList.add(inventoryItem2);
                    }
                }
            }
        }

        for (int int3 = 0; int3 < inventoryItemList.size(); int3++) {
            ItemContainer itemContainer = ((InventoryContainer)inventoryItemList.get(int3)).getInventory();
            if (itemContainer.contains(_type, doInv, ignoreBroken)) {
                ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                return true;
            }
        }

        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return false;
    }

    public boolean contains(String _type) {
        return this.contains(_type, false);
    }

    private static InventoryItem getBestOf(ItemContainer.InventoryItemList inventoryItemList, Comparator<InventoryItem> comparator) {
        if (inventoryItemList != null && !inventoryItemList.isEmpty()) {
            InventoryItem inventoryItem0 = (InventoryItem)inventoryItemList.get(0);

            for (int _int = 1; _int < inventoryItemList.size(); _int++) {
                InventoryItem inventoryItem1 = (InventoryItem)inventoryItemList.get(_int);
                if (comparator.compare(inventoryItem1, inventoryItem0) > 0) {
                    inventoryItem0 = inventoryItem1;
                }
            }

            return inventoryItem0;
        } else {
            return null;
        }
    }

    public InventoryItem getBest(Predicate<InventoryItem> predicate, Comparator<InventoryItem> comparator) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAll(predicate, inventoryItemList);
        InventoryItem inventoryItem = getBestOf(inventoryItemList, comparator);
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return inventoryItem;
    }

    public InventoryItem getBestRecurse(Predicate<InventoryItem> predicate, Comparator<InventoryItem> comparator) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAllRecurse(predicate, inventoryItemList);
        InventoryItem inventoryItem = getBestOf(inventoryItemList, comparator);
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return inventoryItem;
    }

    public InventoryItem getBestType(String _type, Comparator<InventoryItem> comparator) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBest(typePredicate, comparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        }

        return inventoryItem;
    }

    public InventoryItem getBestTypeRecurse(String _type, Comparator<InventoryItem> comparator) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBestRecurse(typePredicate, comparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        }

        return inventoryItem;
    }

    public InventoryItem getBestEval(LuaClosure luaClosure0, LuaClosure luaClosure1) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure0);
        ItemContainer.EvalComparator evalComparator = ((ItemContainer.Comparators)TL_comparators.get()).eval.alloc().init(luaClosure1);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBest(evalPredicate, evalComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).eval.release(evalComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestEvalRecurse(LuaClosure luaClosure0, LuaClosure luaClosure1) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure0);
        ItemContainer.EvalComparator evalComparator = ((ItemContainer.Comparators)TL_comparators.get()).eval.alloc().init(luaClosure1);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBestRecurse(evalPredicate, evalComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).eval.release(evalComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestEvalArg(LuaClosure luaClosure0, LuaClosure luaClosure1, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure0, object);
        ItemContainer.EvalArgComparator evalArgComparator = ((ItemContainer.Comparators)TL_comparators.get()).evalArg.alloc().init(luaClosure1, object);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBest(evalArgPredicate, evalArgComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).evalArg.release(evalArgComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestEvalArgRecurse(LuaClosure luaClosure0, LuaClosure luaClosure1, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure0, object);
        ItemContainer.EvalArgComparator evalArgComparator = ((ItemContainer.Comparators)TL_comparators.get()).evalArg.alloc().init(luaClosure1, object);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBestRecurse(evalArgPredicate, evalArgComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).evalArg.release(evalArgComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestTypeEval(String string, LuaClosure luaClosure) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(string);
        ItemContainer.EvalComparator evalComparator = ((ItemContainer.Comparators)TL_comparators.get()).eval.alloc().init(luaClosure);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBest(typePredicate, evalComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).eval.release(evalComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestTypeEvalRecurse(String string, LuaClosure luaClosure) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(string);
        ItemContainer.EvalComparator evalComparator = ((ItemContainer.Comparators)TL_comparators.get()).eval.alloc().init(luaClosure);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBestRecurse(typePredicate, evalComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).eval.release(evalComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestTypeEvalArg(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(string);
        ItemContainer.EvalArgComparator evalArgComparator = ((ItemContainer.Comparators)TL_comparators.get()).evalArg.alloc().init(luaClosure, object);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBest(typePredicate, evalArgComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).evalArg.release(evalArgComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(string);
        ItemContainer.EvalArgComparator evalArgComparator = ((ItemContainer.Comparators)TL_comparators.get()).evalArg.alloc().init(luaClosure, object);

        InventoryItem inventoryItem;
        try {
            inventoryItem = this.getBestRecurse(typePredicate, evalArgComparator);
        } finally {
            ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
            ((ItemContainer.Comparators)TL_comparators.get()).evalArg.release(evalArgComparator);
        }

        return inventoryItem;
    }

    public InventoryItem getBestCondition(Predicate<InventoryItem> predicate) {
        ItemContainer.ConditionComparator conditionComparator = ((ItemContainer.Comparators)TL_comparators.get()).condition.alloc();
        InventoryItem inventoryItem = this.getBest(predicate, conditionComparator);
        ((ItemContainer.Comparators)TL_comparators.get()).condition.release(conditionComparator);
        if (inventoryItem != null && inventoryItem.getCondition() <= 0) {
            inventoryItem = null;
        }

        return inventoryItem;
    }

    public InventoryItem getBestConditionRecurse(Predicate<InventoryItem> predicate) {
        ItemContainer.ConditionComparator conditionComparator = ((ItemContainer.Comparators)TL_comparators.get()).condition.alloc();
        InventoryItem inventoryItem = this.getBestRecurse(predicate, conditionComparator);
        ((ItemContainer.Comparators)TL_comparators.get()).condition.release(conditionComparator);
        if (inventoryItem != null && inventoryItem.getCondition() <= 0) {
            inventoryItem = null;
        }

        return inventoryItem;
    }

    public InventoryItem getBestCondition(String _type) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        InventoryItem inventoryItem = this.getBestCondition(typePredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return inventoryItem;
    }

    public InventoryItem getBestConditionRecurse(String _type) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        InventoryItem inventoryItem = this.getBestConditionRecurse(typePredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return inventoryItem;
    }

    public InventoryItem getBestConditionEval(LuaClosure luaClosure) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        InventoryItem inventoryItem = this.getBestCondition(evalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return inventoryItem;
    }

    public InventoryItem getBestConditionEvalRecurse(LuaClosure luaClosure) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        InventoryItem inventoryItem = this.getBestConditionRecurse(evalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return inventoryItem;
    }

    public InventoryItem getBestConditionEvalArg(LuaClosure luaClosure, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        InventoryItem inventoryItem = this.getBestCondition(evalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return inventoryItem;
    }

    public InventoryItem getBestConditionEvalArgRecurse(LuaClosure luaClosure, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        InventoryItem inventoryItem = this.getBestConditionRecurse(evalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstEval(LuaClosure luaClosure) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        InventoryItem inventoryItem = this.getFirst(evalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstEvalArg(LuaClosure luaClosure, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        InventoryItem inventoryItem = this.getFirst(evalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return inventoryItem;
    }

    public boolean containsEval(LuaClosure luaClosure) {
        return this.getFirstEval(luaClosure) != null;
    }

    public boolean containsEvalArg(LuaClosure luaClosure, Object object) {
        return this.getFirstEvalArg(luaClosure, object) != null;
    }

    public boolean containsEvalRecurse(LuaClosure luaClosure) {
        return this.getFirstEvalRecurse(luaClosure) != null;
    }

    public boolean containsEvalArgRecurse(LuaClosure luaClosure, Object object) {
        return this.getFirstEvalArgRecurse(luaClosure, object) != null;
    }

    public boolean containsTag(String tag) {
        return this.getFirstTag(tag) != null;
    }

    public boolean containsTagEval(String string, LuaClosure luaClosure) {
        return this.getFirstTagEval(string, luaClosure) != null;
    }

    public boolean containsTagRecurse(String tag) {
        return this.getFirstTagRecurse(tag) != null;
    }

    public boolean containsTagEvalRecurse(String string, LuaClosure luaClosure) {
        return this.getFirstTagEvalRecurse(string, luaClosure) != null;
    }

    public boolean containsTagEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        return this.getFirstTagEvalArgRecurse(string, luaClosure, object) != null;
    }

    public boolean containsTypeEvalRecurse(String string, LuaClosure luaClosure) {
        return this.getFirstTypeEvalRecurse(string, luaClosure) != null;
    }

    public boolean containsTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        return this.getFirstTypeEvalArgRecurse(string, luaClosure, object) != null;
    }

    private static boolean compareType(String string0, String string1) {
        if (string0 != null && string0.contains("/")) {
            int _int = string0.indexOf(string1);
            if (_int == -1) {
                return false;
            } else {
                char char0 = _int > 0 ? string0.charAt(_int - 1) : 0;
                char char1 = _int + string1.length() < string0.length() ? string0.charAt(_int + string1.length()) : 0;
                return char0 == 0 && char1 == '/' || char0 == '/' && char1 == 0 || char0 == '/' && char1 == '/';
            }
        } else {
            return string0.equals(string1);
        }
    }

    private static boolean compareType(String string, InventoryItem inventoryItem) {
        return string != null && string.indexOf(46) == -1
            ? compareType(string, inventoryItem.getType())
            : compareType(string, inventoryItem.getFullType()) || compareType(string, inventoryItem.getType());
    }

    public InventoryItem getFirst(Predicate<InventoryItem> predicate) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem == null) {
                this.Items.remove(_int);
                _int--;
            } else if (predicate.test(inventoryItem)) {
                return inventoryItem;
            }
        }

        return null;
    }

    public InventoryItem getFirstRecurse(Predicate<InventoryItem> predicate) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();

        for (int int0 = 0; int0 < this.Items.size(); int0++) {
            InventoryItem inventoryItem0 = (InventoryItem)this.Items.get(int0);
            if (inventoryItem0 == null) {
                this.Items.remove(int0);
                int0--;
            } else {
                if (predicate.test(inventoryItem0)) {
                    ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                    return inventoryItem0;
                }

                if (inventoryItem0 instanceof InventoryContainer) {
                    inventoryItemList.add(inventoryItem0);
                }
            }
        }

        for (int int1 = 0; int1 < inventoryItemList.size(); int1++) {
            ItemContainer itemContainer = ((InventoryContainer)inventoryItemList.get(int1)).getInventory();
            InventoryItem inventoryItem1 = itemContainer.getFirstRecurse(predicate);
            if (inventoryItem1 != null) {
                ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                return inventoryItem1;
            }
        }

        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return null;
    }

    public ArrayList<InventoryItem> getSome(Predicate<InventoryItem> predicate, int count, ArrayList<InventoryItem> result) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem == null) {
                this.Items.remove(_int);
                _int--;
            } else if (predicate.test(inventoryItem)) {
                result.add(inventoryItem);
                if (result.size() >= count) {
                    break;
                }
            }
        }

        return result;
    }

    public ArrayList<InventoryItem> getSomeRecurse(Predicate<InventoryItem> predicate, int count, ArrayList<InventoryItem> result) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();

        for (int int0 = 0; int0 < this.Items.size(); int0++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(int0);
            if (inventoryItem == null) {
                this.Items.remove(int0);
                int0--;
            } else {
                if (predicate.test(inventoryItem)) {
                    result.add(inventoryItem);
                    if (result.size() >= count) {
                        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                        return result;
                    }
                }

                if (inventoryItem instanceof InventoryContainer) {
                    inventoryItemList.add(inventoryItem);
                }
            }
        }

        for (int int1 = 0; int1 < inventoryItemList.size(); int1++) {
            ItemContainer itemContainer = ((InventoryContainer)inventoryItemList.get(int1)).getInventory();
            itemContainer.getSomeRecurse(predicate, count, result);
            if (result.size() >= count) {
                break;
            }
        }

        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return result;
    }

    public ArrayList<InventoryItem> getAll(Predicate<InventoryItem> predicate, ArrayList<InventoryItem> result) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem == null) {
                this.Items.remove(_int);
                _int--;
            } else if (predicate.test(inventoryItem)) {
                result.add(inventoryItem);
            }
        }

        return result;
    }

    public ArrayList<InventoryItem> getAllRecurse(Predicate<InventoryItem> predicate, ArrayList<InventoryItem> result) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();

        for (int int0 = 0; int0 < this.Items.size(); int0++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(int0);
            if (inventoryItem == null) {
                this.Items.remove(int0);
                int0--;
            } else {
                if (predicate.test(inventoryItem)) {
                    result.add(inventoryItem);
                }

                if (inventoryItem instanceof InventoryContainer) {
                    inventoryItemList.add(inventoryItem);
                }
            }
        }

        for (int int1 = 0; int1 < inventoryItemList.size(); int1++) {
            ItemContainer itemContainer = ((InventoryContainer)inventoryItemList.get(int1)).getInventory();
            itemContainer.getAllRecurse(predicate, result);
        }

        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return result;
    }

    public int getCount(Predicate<InventoryItem> predicate) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAll(predicate, inventoryItemList);
        int _int = inventoryItemList.size();
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return _int;
    }

    public int getCountRecurse(Predicate<InventoryItem> predicate) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAllRecurse(predicate, inventoryItemList);
        int _int = inventoryItemList.size();
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return _int;
    }

    public int getCountTag(String tag) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        int _int = this.getCount(tagPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return _int;
    }

    public int getCountTagEval(String string, LuaClosure luaClosure) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        int _int = this.getCount(tagEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return _int;
    }

    public int getCountTagEvalArg(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        int _int = this.getCount(tagEvalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return _int;
    }

    public int getCountTagRecurse(String tag) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        int _int = this.getCountRecurse(tagPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return _int;
    }

    public int getCountTagEvalRecurse(String string, LuaClosure luaClosure) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        int _int = this.getCountRecurse(tagEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return _int;
    }

    public int getCountTagEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        int _int = this.getCountRecurse(tagEvalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return _int;
    }

    public int getCountType(String _type) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        int _int = this.getCount(typePredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return _int;
    }

    public int getCountTypeEval(String string, LuaClosure luaClosure) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        int _int = this.getCount(typeEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return _int;
    }

    public int getCountTypeEvalArg(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        int _int = this.getCount(typeEvalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return _int;
    }

    public int getCountTypeRecurse(String _type) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        int _int = this.getCountRecurse(typePredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return _int;
    }

    public int getCountTypeEvalRecurse(String string, LuaClosure luaClosure) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        int _int = this.getCountRecurse(typeEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return _int;
    }

    public int getCountTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        int _int = this.getCountRecurse(typeEvalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return _int;
    }

    public int getCountEval(LuaClosure luaClosure) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        int _int = this.getCount(evalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return _int;
    }

    public int getCountEvalArg(LuaClosure luaClosure, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        int _int = this.getCount(evalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return _int;
    }

    public int getCountEvalRecurse(LuaClosure luaClosure) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        int _int = this.getCountRecurse(evalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return _int;
    }

    public int getCountEvalArgRecurse(LuaClosure luaClosure, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        int _int = this.getCountRecurse(evalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return _int;
    }

    public InventoryItem getFirstCategory(String category) {
        ItemContainer.CategoryPredicate categoryPredicate = ((ItemContainer.Predicates)TL_predicates.get()).category.alloc().init(category);
        InventoryItem inventoryItem = this.getFirst(categoryPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).category.release(categoryPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstCategoryRecurse(String category) {
        ItemContainer.CategoryPredicate categoryPredicate = ((ItemContainer.Predicates)TL_predicates.get()).category.alloc().init(category);
        InventoryItem inventoryItem = this.getFirstRecurse(categoryPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).category.release(categoryPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstEvalRecurse(LuaClosure luaClosure) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        InventoryItem inventoryItem = this.getFirstRecurse(evalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstEvalArgRecurse(LuaClosure luaClosure, Object object) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        InventoryItem inventoryItem = this.getFirstRecurse(evalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTag(String tag) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        InventoryItem inventoryItem = this.getFirst(tagPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTagRecurse(String tag) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        InventoryItem inventoryItem = this.getFirstRecurse(tagPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTagEval(String string, LuaClosure luaClosure) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        InventoryItem inventoryItem = this.getFirstRecurse(tagEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTagEvalRecurse(String string, LuaClosure luaClosure) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        InventoryItem inventoryItem = this.getFirstRecurse(tagEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTagEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        InventoryItem inventoryItem = this.getFirstRecurse(tagEvalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstType(String _type) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        InventoryItem inventoryItem = this.getFirst(typePredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTypeRecurse(String _type) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        InventoryItem inventoryItem = this.getFirstRecurse(typePredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTypeEval(String string, LuaClosure luaClosure) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        InventoryItem inventoryItem = this.getFirstRecurse(typeEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTypeEvalRecurse(String string, LuaClosure luaClosure) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        InventoryItem inventoryItem = this.getFirstRecurse(typeEvalPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return inventoryItem;
    }

    public InventoryItem getFirstTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        InventoryItem inventoryItem = this.getFirstRecurse(typeEvalArgPredicate);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return inventoryItem;
    }

    public ArrayList<InventoryItem> getSomeCategory(String category, int count, ArrayList<InventoryItem> result) {
        ItemContainer.CategoryPredicate categoryPredicate = ((ItemContainer.Predicates)TL_predicates.get()).category.alloc().init(category);
        ArrayList arrayList = this.getSome(categoryPredicate, count, result);
        ((ItemContainer.Predicates)TL_predicates.get()).category.release(categoryPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getSomeCategoryRecurse(String category, int count, ArrayList<InventoryItem> result) {
        ItemContainer.CategoryPredicate categoryPredicate = ((ItemContainer.Predicates)TL_predicates.get()).category.alloc().init(category);
        ArrayList arrayList = this.getSomeRecurse(categoryPredicate, count, result);
        ((ItemContainer.Predicates)TL_predicates.get()).category.release(categoryPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getSomeTag(String tag, int count, ArrayList<InventoryItem> result) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        ArrayList arrayList = this.getSome(tagPredicate, count, result);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getSomeTagEval(String string, LuaClosure luaClosure, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getSome(tagEvalPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeTagEvalArg(String string, LuaClosure luaClosure, Object object, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getSome(tagEvalArgPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeTagRecurse(String tag, int count, ArrayList<InventoryItem> result) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        ArrayList arrayList = this.getSomeRecurse(tagPredicate, count, result);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getSomeTagEvalRecurse(String string, LuaClosure luaClosure, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getSomeRecurse(tagEvalPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeTagEvalArgRecurse(String string, LuaClosure luaClosure, Object object, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getSomeRecurse(tagEvalArgPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeType(String _type, int count, ArrayList<InventoryItem> result) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        ArrayList arrayList = this.getSome(typePredicate, count, result);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getSomeTypeEval(String string, LuaClosure luaClosure, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getSome(typeEvalPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeTypeEvalArg(String string, LuaClosure luaClosure, Object object, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getSome(typeEvalArgPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeTypeRecurse(String _type, int count, ArrayList<InventoryItem> result) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        ArrayList arrayList = this.getSomeRecurse(typePredicate, count, result);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getSomeTypeEvalRecurse(String string, LuaClosure luaClosure, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getSomeRecurse(typeEvalPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeTypeEvalArgRecurse(
        String string, LuaClosure luaClosure, Object object, int _int, ArrayList<InventoryItem> arrayList1
    ) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getSomeRecurse(typeEvalArgPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeEval(LuaClosure luaClosure, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        ArrayList arrayList0 = this.getSome(evalPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeEvalArg(LuaClosure luaClosure, Object object, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        ArrayList arrayList0 = this.getSome(evalArgPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeEvalRecurse(LuaClosure luaClosure, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        ArrayList arrayList0 = this.getSomeRecurse(evalPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeEvalArgRecurse(LuaClosure luaClosure, Object object, int _int, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        ArrayList arrayList0 = this.getSomeRecurse(evalArgPredicate, _int, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllCategory(String category, ArrayList<InventoryItem> result) {
        ItemContainer.CategoryPredicate categoryPredicate = ((ItemContainer.Predicates)TL_predicates.get()).category.alloc().init(category);
        ArrayList arrayList = this.getAll(categoryPredicate, result);
        ((ItemContainer.Predicates)TL_predicates.get()).category.release(categoryPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getAllCategoryRecurse(String category, ArrayList<InventoryItem> result) {
        ItemContainer.CategoryPredicate categoryPredicate = ((ItemContainer.Predicates)TL_predicates.get()).category.alloc().init(category);
        ArrayList arrayList = this.getAllRecurse(categoryPredicate, result);
        ((ItemContainer.Predicates)TL_predicates.get()).category.release(categoryPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getAllTag(String tag, ArrayList<InventoryItem> result) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        ArrayList arrayList = this.getAll(tagPredicate, result);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getAllTagEval(String string, LuaClosure luaClosure, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getAll(tagEvalPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllTagEvalArg(String string, LuaClosure luaClosure, Object object, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getAll(tagEvalArgPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllTagRecurse(String tag, ArrayList<InventoryItem> result) {
        ItemContainer.TagPredicate tagPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tag.alloc().init(tag);
        ArrayList arrayList = this.getAllRecurse(tagPredicate, result);
        ((ItemContainer.Predicates)TL_predicates.get()).tag.release(tagPredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getAllTagEvalRecurse(String string, LuaClosure luaClosure, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalPredicate tagEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).tagEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getAllRecurse(tagEvalPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEval.release(tagEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllTagEvalArgRecurse(String string, LuaClosure luaClosure, Object object, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TagEvalArgPredicate tagEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .tagEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getAllRecurse(tagEvalArgPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).tagEvalArg.release(tagEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllType(String _type, ArrayList<InventoryItem> result) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        ArrayList arrayList = this.getAll(typePredicate, result);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getAllTypeEval(String string, LuaClosure luaClosure, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getAll(typeEvalPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllTypeEvalArg(String string, LuaClosure luaClosure, Object object, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getAll(typeEvalArgPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllTypeRecurse(String _type, ArrayList<InventoryItem> result) {
        ItemContainer.TypePredicate typePredicate = ((ItemContainer.Predicates)TL_predicates.get()).type.alloc().init(_type);
        ArrayList arrayList = this.getAllRecurse(typePredicate, result);
        ((ItemContainer.Predicates)TL_predicates.get()).type.release(typePredicate);
        return arrayList;
    }

    public ArrayList<InventoryItem> getAllTypeEvalRecurse(String string, LuaClosure luaClosure, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalPredicate typeEvalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).typeEval.alloc().init(string, luaClosure);
        ArrayList arrayList0 = this.getAllRecurse(typeEvalPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEval.release(typeEvalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.TypeEvalArgPredicate typeEvalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get())
            .typeEvalArg
            .alloc()
            .init(string, luaClosure, object);
        ArrayList arrayList0 = this.getAllRecurse(typeEvalArgPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).typeEvalArg.release(typeEvalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllEval(LuaClosure luaClosure, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        ArrayList arrayList0 = this.getAll(evalPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllEvalArg(LuaClosure luaClosure, Object object, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        ArrayList arrayList0 = this.getAll(evalArgPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllEvalRecurse(LuaClosure luaClosure, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalPredicate evalPredicate = ((ItemContainer.Predicates)TL_predicates.get()).eval.alloc().init(luaClosure);
        ArrayList arrayList0 = this.getAllRecurse(evalPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).eval.release(evalPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getAllEvalArgRecurse(LuaClosure luaClosure, Object object, ArrayList<InventoryItem> arrayList1) {
        ItemContainer.EvalArgPredicate evalArgPredicate = ((ItemContainer.Predicates)TL_predicates.get()).evalArg.alloc().init(luaClosure, object);
        ArrayList arrayList0 = this.getAllRecurse(evalArgPredicate, arrayList1);
        ((ItemContainer.Predicates)TL_predicates.get()).evalArg.release(evalArgPredicate);
        return arrayList0;
    }

    public ArrayList<InventoryItem> getSomeCategory(String category, int count) {
        return this.getSomeCategory(category, count, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeEval(LuaClosure luaClosure, int _int) {
        return this.getSomeEval(luaClosure, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeEvalArg(LuaClosure luaClosure, Object object, int _int) {
        return this.getSomeEvalArg(luaClosure, object, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTypeEval(String string, LuaClosure luaClosure, int _int) {
        return this.getSomeTypeEval(string, luaClosure, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTypeEvalArg(String string, LuaClosure luaClosure, Object object, int _int) {
        return this.getSomeTypeEvalArg(string, luaClosure, object, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeEvalRecurse(LuaClosure luaClosure, int _int) {
        return this.getSomeEvalRecurse(luaClosure, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeEvalArgRecurse(LuaClosure luaClosure, Object object, int _int) {
        return this.getSomeEvalArgRecurse(luaClosure, object, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTag(String tag, int count) {
        return this.getSomeTag(tag, count, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTagRecurse(String tag, int count) {
        return this.getSomeTagRecurse(tag, count, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTagEvalRecurse(String string, LuaClosure luaClosure, int _int) {
        return this.getSomeTagEvalRecurse(string, luaClosure, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTagEvalArgRecurse(String string, LuaClosure luaClosure, Object object, int _int) {
        return this.getSomeTagEvalArgRecurse(string, luaClosure, object, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeType(String _type, int count) {
        return this.getSomeType(_type, count, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTypeRecurse(String _type, int count) {
        return this.getSomeTypeRecurse(_type, count, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTypeEvalRecurse(String string, LuaClosure luaClosure, int _int) {
        return this.getSomeTypeEvalRecurse(string, luaClosure, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getSomeTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object, int _int) {
        return this.getSomeTypeEvalArgRecurse(string, luaClosure, object, _int, new ArrayList());
    }

    public ArrayList<InventoryItem> getAll(Predicate<InventoryItem> predicate) {
        return this.getAll(predicate, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllCategory(String category) {
        return this.getAllCategory(category, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllEval(LuaClosure luaClosure) {
        return this.getAllEval(luaClosure, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllEvalArg(LuaClosure luaClosure, Object object) {
        return this.getAllEvalArg(luaClosure, object, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTagEval(String string, LuaClosure luaClosure) {
        return this.getAllTagEval(string, luaClosure, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTagEvalArg(String string, LuaClosure luaClosure, Object object) {
        return this.getAllTagEvalArg(string, luaClosure, object, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTypeEval(String string, LuaClosure luaClosure) {
        return this.getAllTypeEval(string, luaClosure, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTypeEvalArg(String string, LuaClosure luaClosure, Object object) {
        return this.getAllTypeEvalArg(string, luaClosure, object, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllEvalRecurse(LuaClosure luaClosure) {
        return this.getAllEvalRecurse(luaClosure, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllEvalArgRecurse(LuaClosure luaClosure, Object object) {
        return this.getAllEvalArgRecurse(luaClosure, object, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllType(String _type) {
        return this.getAllType(_type, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTypeRecurse(String _type) {
        return this.getAllTypeRecurse(_type, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTypeEvalRecurse(String string, LuaClosure luaClosure) {
        return this.getAllTypeEvalRecurse(string, luaClosure, new ArrayList());
    }

    public ArrayList<InventoryItem> getAllTypeEvalArgRecurse(String string, LuaClosure luaClosure, Object object) {
        return this.getAllTypeEvalArgRecurse(string, luaClosure, object, new ArrayList());
    }

    public InventoryItem FindAndReturnCategory(String category) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.getCategory().equals(category)) {
                return inventoryItem;
            }
        }

        return null;
    }

    public ArrayList<InventoryItem> FindAndReturn(String _type, int count) {
        return this.getSomeType(_type, count);
    }

    public InventoryItem FindAndReturn(String _type, ArrayList<InventoryItem> itemToCheck) {
        if (_type == null) {
            return null;
        } else {
            for (int _int = 0; _int < this.Items.size(); _int++) {
                InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
                if (inventoryItem.type != null && compareType(_type, inventoryItem) && !itemToCheck.contains(inventoryItem)) {
                    return inventoryItem;
                }
            }

            return null;
        }
    }

    public InventoryItem FindAndReturn(String _type) {
        return this.getFirstType(_type);
    }

    public ArrayList<InventoryItem> FindAll(String _type) {
        return this.getAllType(_type);
    }

    public InventoryItem FindAndReturnStack(String _type) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem0 = (InventoryItem)this.Items.get(_int);
            if (compareType(_type, inventoryItem0)) {
                InventoryItem inventoryItem1 = InventoryItemFactory.CreateItem(inventoryItem0.module + "." + _type);
                if (inventoryItem0.CanStack(inventoryItem1)) {
                    return inventoryItem0;
                }
            }
        }

        return null;
    }

    public InventoryItem FindAndReturnStack(InventoryItem itemlike) {
        String string = itemlike.type;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if ((inventoryItem.type == null ? string == null : inventoryItem.type.equals(string)) && inventoryItem.CanStack(itemlike)) {
                return inventoryItem;
            }
        }

        return null;
    }

    public boolean HasType(ItemType itemType) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.cat == itemType) {
                return true;
            }
        }

        return false;
    }

    public void Remove(InventoryItem item) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem == item) {
                if (item.uses > 1) {
                    item.uses--;
                } else {
                    this.Items.remove(item);
                }

                item.container = null;
                this.drawDirty = true;
                this.dirty = true;
                if (this.parent != null) {
                    this.dirty = true;
                }

                if (this.parent instanceof IsoDeadBody) {
                    ((IsoDeadBody)this.parent).checkClothing(item);
                }

                if (this.parent instanceof IsoMannequin) {
                    ((IsoMannequin)this.parent).checkClothing(item);
                }

                return;
            }
        }
    }

    public void DoRemoveItem(InventoryItem item) {
        this.drawDirty = true;
        if (this.parent != null) {
            this.dirty = true;
        }

        this.Items.remove(item);
        item.container = null;
        if (this.parent instanceof IsoDeadBody) {
            ((IsoDeadBody)this.parent).checkClothing(item);
        }

        if (this.parent instanceof IsoMannequin) {
            ((IsoMannequin)this.parent).checkClothing(item);
        }
    }

    public void Remove(String itemTypes) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.type.equals(itemTypes)) {
                if (inventoryItem.uses > 1) {
                    inventoryItem.uses--;
                } else {
                    this.Items.remove(inventoryItem);
                }

                inventoryItem.container = null;
                this.drawDirty = true;
                this.dirty = true;
                if (this.parent != null) {
                    this.dirty = true;
                }

                return;
            }
        }
    }

    public InventoryItem Remove(ItemType itemType) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.cat == itemType) {
                this.Items.remove(inventoryItem);
                inventoryItem.container = null;
                this.drawDirty = true;
                this.dirty = true;
                if (this.parent != null) {
                    this.dirty = true;
                }

                return inventoryItem;
            }
        }

        return null;
    }

    public InventoryItem Find(ItemType itemType) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.cat == itemType) {
                return inventoryItem;
            }
        }

        return null;
    }

    public void RemoveAll(String itemType) {
        this.drawDirty = true;
        if (this.parent != null) {
            this.dirty = true;
        }

        ArrayList arrayList = new ArrayList();

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem0 = (InventoryItem)this.Items.get(_int);
            if (inventoryItem0.type.equals(itemType)) {
                inventoryItem0.container = null;
                arrayList.add(inventoryItem0);
                this.dirty = true;
            }
        }

        for (InventoryItem inventoryItem1 : arrayList) {
            this.Items.remove(inventoryItem1);
        }
    }

    public boolean RemoveOneOf(String String, boolean insideInv) {
        this.drawDirty = true;
        if (this.parent != null && !(this.parent instanceof IsoGameCharacter)) {
            this.dirty = true;
        }

        for (int int0 = 0; int0 < this.Items.size(); int0++) {
            InventoryItem inventoryItem0 = (InventoryItem)this.Items.get(int0);
            if (inventoryItem0.getFullType().equals(String) || inventoryItem0.type.equals(String)) {
                if (inventoryItem0.uses > 1) {
                    inventoryItem0.uses--;
                } else {
                    inventoryItem0.container = null;
                    this.Items.remove(inventoryItem0);
                }

                this.dirty = true;
                return true;
            }
        }

        if (insideInv) {
            for (int int1 = 0; int1 < this.Items.size(); int1++) {
                InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(int1);
                if (inventoryItem1 instanceof InventoryContainer
                    && ((InventoryContainer)inventoryItem1).getItemContainer() != null
                    && ((InventoryContainer)inventoryItem1).getItemContainer().RemoveOneOf(String, insideInv)) {
                    return true;
                }
            }
        }

        return false;
    }

    public void RemoveOneOf(String String) {
        this.RemoveOneOf(String, true);
    }

    /** @deprecated */
    public int getWeight() {
        if (this.parent instanceof IsoPlayer && ((IsoPlayer)this.parent).isGhostMode()) {
            return 0;
        } else {
            float _float = 0.0F;

            for (int _int = 0; _int < this.Items.size(); _int++) {
                InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
                _float += inventoryItem.ActualWeight * (float)inventoryItem.uses;
            }

            return (int)(_float * ((float)this.weightReduction / 0.01F));
        }
    }

    public float getContentsWeight() {
        float _float = 0.0F;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            _float += inventoryItem.getUnequippedWeight();
        }

        return _float;
    }

    public float getMaxWeight() {
        return this.parent instanceof IsoGameCharacter ? (float)((IsoGameCharacter)this.parent).getMaxWeight() : (float)this.Capacity;
    }

    public float getCapacityWeight() {
        if (this.parent instanceof IsoPlayer) {
            if (Core.bDebug && ((IsoPlayer)this.parent).isGhostMode()
                || !((IsoPlayer)this.parent).isAccessLevel("None") && ((IsoPlayer)this.parent).isUnlimitedCarry()) {
                return 0.0F;
            }

            if (((IsoPlayer)this.parent).isUnlimitedCarry()) {
                return 0.0F;
            }
        }

        return this.parent instanceof IsoGameCharacter ? ((IsoGameCharacter)this.parent).getInventoryWeight() : this.getContentsWeight();
    }

    public boolean isEmpty() {
        return this.Items == null || this.Items.isEmpty();
    }

    public boolean isMicrowave() {
        return "microwave".equals(this.getType());
    }

    private boolean isSquareInRoom(IsoGridSquare isoGridSquare) {
        return isoGridSquare == null ? false : isoGridSquare.getRoom() != null;
    }

    private boolean isSquarePowered(IsoGridSquare isoGridSquare0) {
        if (isoGridSquare0 == null) {
            return false;
        } else {
            boolean _boolean = IsoWorld.instance.isHydroPowerOn();
            if (_boolean && isoGridSquare0.getRoom() != null) {
                return true;
            } else if (isoGridSquare0.haveElectricity()) {
                return true;
            } else {
                if (_boolean && isoGridSquare0.getRoom() == null) {
                    IsoGridSquare isoGridSquare1 = isoGridSquare0.nav[IsoDirections.N.index()];
                    IsoGridSquare isoGridSquare2 = isoGridSquare0.nav[IsoDirections.S.index()];
                    IsoGridSquare isoGridSquare3 = isoGridSquare0.nav[IsoDirections.W.index()];
                    IsoGridSquare isoGridSquare4 = isoGridSquare0.nav[IsoDirections.E.index()];
                    if (this.isSquareInRoom(isoGridSquare1)
                        || this.isSquareInRoom(isoGridSquare2)
                        || this.isSquareInRoom(isoGridSquare3)
                        || this.isSquareInRoom(isoGridSquare4)) {
                        return true;
                    }
                }

                return false;
            }
        }
    }

    public boolean isPowered() {
        if (this.parent != null && this.parent.getObjectIndex() != -1) {
            IsoGridSquare isoGridSquare0 = this.parent.getSquare();
            if (this.isSquarePowered(isoGridSquare0)) {
                return true;
            } else {
                this.parent.getSpriteGridObjects(s_tempObjects);

                for (int _int = 0; _int < s_tempObjects.size(); _int++) {
                    IsoObject isoObject = (IsoObject)s_tempObjects.get(_int);
                    if (isoObject != this.parent) {
                        IsoGridSquare isoGridSquare1 = isoObject.getSquare();
                        if (this.isSquarePowered(isoGridSquare1)) {
                            return true;
                        }
                    }
                }

                return false;
            }
        } else {
            return false;
        }
    }

    public float getTemprature() {
        if (this.customTemperature != 0.0F) {
            return this.customTemperature;
        } else {
            boolean _boolean = false;
            if (this.getParent() != null && this.getParent().getSprite() != null) {
                _boolean = this.getParent().getSprite().getProperties().Is("IsFridge");
            }

            if (this.isPowered()) {
                if (this.type.equals("fridge") || this.type.equals("freezer") || _boolean) {
                    return 0.2F;
                }

                if (("stove".equals(this.type) || "microwave".equals(this.type)) && this.parent instanceof IsoStove) {
                    return ((IsoStove)this.parent).getCurrentTemperature() / 100.0F;
                }
            }

            if ("barbecue".equals(this.type) && this.parent instanceof IsoBarbecue) {
                return ((IsoBarbecue)this.parent).getTemperature();
            } else if ("fireplace".equals(this.type) && this.parent instanceof IsoFireplace) {
                return ((IsoFireplace)this.parent).getTemperature();
            } else if ("woodstove".equals(this.type) && this.parent instanceof IsoFireplace) {
                return ((IsoFireplace)this.parent).getTemperature();
            } else if ((this.type.equals("fridge") || this.type.equals("freezer") || _boolean)
                && zombie.GameTime.instance.NightsSurvived == zombie.SandboxOptions.instance.getElecShutModifier()
                && zombie.GameTime.instance.getTimeOfDay() < 13.0F) {
                float _float = (zombie.GameTime.instance.getTimeOfDay() - 7.0F) / 6.0F;
                return zombie.GameTime.instance.Lerp(0.2F, 1.0F, _float);
            } else {
                return 1.0F;
            }
        }
    }

    public boolean isTemperatureChanging() {
        return this.parent instanceof IsoStove ? ((IsoStove)this.parent).isTemperatureChanging() : false;
    }

    public ArrayList<InventoryItem> save(ByteBuffer output, IsoGameCharacter noCompress) throws IOException {
        zombie.GameWindow.WriteString(output, this.type);
        output.put((byte)(this.bExplored ? 1 : 0));
        ArrayList arrayList = CompressIdenticalItems.save(output, this.Items, null);
        output.put((byte)(this.isHasBeenLooted() ? 1 : 0));
        output.putInt(this.Capacity);
        return arrayList;
    }

    public ArrayList<InventoryItem> save(ByteBuffer output) throws IOException {
        return this.save(output, null);
    }

    public ArrayList<InventoryItem> load(ByteBuffer input, int WorldVersion) throws IOException {
        this.type = zombie.GameWindow.ReadString(input);
        this.bExplored = input.get() == 1;
        ArrayList arrayList = CompressIdenticalItems.load(input, WorldVersion, this.Items, this.IncludingObsoleteItems);

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            inventoryItem.container = this;
        }

        this.setHasBeenLooted(input.get() == 1);
        this.Capacity = input.getInt();
        this.dirty = false;
        return arrayList;
    }

    public boolean isDrawDirty() {
        return this.drawDirty;
    }

    public void setDrawDirty(boolean b) {
        this.drawDirty = b;
    }

    public InventoryItem getBestWeapon(SurvivorDesc desc) {
        InventoryItem inventoryItem0 = null;
        float float0 = -1.0E7F;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(_int);
            if (inventoryItem1 instanceof HandWeapon) {
                float float1 = inventoryItem1.getScore(desc);
                if (float1 >= float0) {
                    float0 = float1;
                    inventoryItem0 = inventoryItem1;
                }
            }
        }

        return inventoryItem0;
    }

    public InventoryItem getBestWeapon() {
        InventoryItem inventoryItem0 = null;
        float float0 = 0.0F;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(_int);
            if (inventoryItem1 instanceof HandWeapon) {
                float float1 = inventoryItem1.getScore(null);
                if (float1 >= float0) {
                    float0 = float1;
                    inventoryItem0 = inventoryItem1;
                }
            }
        }

        return inventoryItem0;
    }

    public float getTotalFoodScore(SurvivorDesc desc) {
        float _float = 0.0F;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem instanceof Food) {
                _float += inventoryItem.getScore(desc);
            }
        }

        return _float;
    }

    public float getTotalWeaponScore(SurvivorDesc desc) {
        float _float = 0.0F;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem instanceof HandWeapon) {
                _float += inventoryItem.getScore(desc);
            }
        }

        return _float;
    }

    public InventoryItem getBestFood(SurvivorDesc descriptor) {
        InventoryItem inventoryItem0 = null;
        float float0 = 0.0F;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(_int);
            if (inventoryItem1 instanceof Food) {
                float float1 = inventoryItem1.getScore(descriptor);
                if (((Food)inventoryItem1).isbDangerousUncooked() && !inventoryItem1.isCooked()) {
                    float1 *= 0.2F;
                }

                if (((Food)inventoryItem1).Age > (float)inventoryItem1.OffAge) {
                    float1 *= 0.2F;
                }

                if (float1 >= float0) {
                    float0 = float1;
                    inventoryItem0 = inventoryItem1;
                }
            }
        }

        return inventoryItem0;
    }

    public InventoryItem getBestBandage(SurvivorDesc descriptor) {
        InventoryItem inventoryItem0 = null;

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(_int);
            if (inventoryItem1.isCanBandage()) {
                inventoryItem0 = inventoryItem1;
                break;
            }
        }

        return inventoryItem0;
    }

    public int getNumItems(String item) {
        int int0 = 0;
        if (item.contains("Type:")) {
            for (int int1 = 0; int1 < this.Items.size(); int1++) {
                InventoryItem inventoryItem0 = (InventoryItem)this.Items.get(int1);
                if (inventoryItem0 instanceof Food && item.contains("Food")) {
                    int0 += inventoryItem0.uses;
                }

                if (inventoryItem0 instanceof HandWeapon && item.contains("Weapon")) {
                    int0 += inventoryItem0.uses;
                }
            }
        } else {
            for (int int2 = 0; int2 < this.Items.size(); int2++) {
                InventoryItem inventoryItem1 = (InventoryItem)this.Items.get(int2);
                if (inventoryItem1.type.equals(item)) {
                    int0 += inventoryItem1.uses;
                }
            }
        }

        return int0;
    }

    public boolean isActive() {
        return this.active;
    }

    public void setActive(boolean _active) {
        this.active = _active;
    }

    public boolean isDirty() {
        return this.dirty;
    }

    public void setDirty(boolean _dirty) {
        this.dirty = _dirty;
    }

    public boolean isIsDevice() {
        return this.IsDevice;
    }

    public void setIsDevice(boolean _IsDevice) {
        this.IsDevice = _IsDevice;
    }

    public float getAgeFactor() {
        return this.ageFactor;
    }

    public void setAgeFactor(float _ageFactor) {
        this.ageFactor = _ageFactor;
    }

    public float getCookingFactor() {
        return this.CookingFactor;
    }

    public void setCookingFactor(float _CookingFactor) {
        this.CookingFactor = _CookingFactor;
    }

    public ArrayList<InventoryItem> getItems() {
        return this.Items;
    }

    public void setItems(ArrayList<InventoryItem> _Items) {
        this.Items = _Items;
    }

    public IsoObject getParent() {
        return this.parent;
    }

    public void setParent(IsoObject _parent) {
        this.parent = _parent;
    }

    public IsoGridSquare getSourceGrid() {
        return this.SourceGrid;
    }

    public void setSourceGrid(IsoGridSquare _SourceGrid) {
        this.SourceGrid = _SourceGrid;
    }

    public String getType() {
        return this.type;
    }

    public void setType(String _type) {
        this.type = _type;
    }

    public void clear() {
        this.Items.clear();
        this.dirty = true;
        this.drawDirty = true;
    }

    public int getWaterContainerCount() {
        int int0 = 0;

        for (int int1 = 0; int1 < this.Items.size(); int1++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(int1);
            if (inventoryItem.CanStoreWater) {
                int0++;
            }
        }

        return int0;
    }

    public InventoryItem FindWaterSource() {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.isWaterSource()) {
                if (!(inventoryItem instanceof Drainable)) {
                    return inventoryItem;
                }

                if (((Drainable)inventoryItem).getUsedDelta() > 0.0F) {
                    return inventoryItem;
                }
            }
        }

        return null;
    }

    public ArrayList<InventoryItem> getAllWaterFillables() {
        tempList.clear();

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.CanStoreWater) {
                tempList.add(inventoryItem);
            }
        }

        return tempList;
    }

    public int getItemCount(String _type) {
        return this.getCountType(_type);
    }

    public int getItemCountRecurse(String _type) {
        return this.getCountTypeRecurse(_type);
    }

    public int getItemCount(String _type, boolean doBags) {
        return doBags ? this.getCountTypeRecurse(_type) : this.getCountType(_type);
    }

    private static int getUses(ItemContainer.InventoryItemList inventoryItemList) {
        int int0 = 0;

        for (int int1 = 0; int1 < inventoryItemList.size(); int1++) {
            DrainableComboItem drainableComboItem = Type.tryCastTo((InventoryItem)inventoryItemList.get(int1), DrainableComboItem.class);
            if (drainableComboItem != null) {
                int0 += drainableComboItem.getDrainableUsesInt();
            } else {
                int0++;
            }
        }

        return int0;
    }

    public int getUsesRecurse(Predicate<InventoryItem> predicate) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAllRecurse(predicate, inventoryItemList);
        int _int = getUses(inventoryItemList);
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return _int;
    }

    public int getUsesType(String _type) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAllType(_type, inventoryItemList);
        int _int = getUses(inventoryItemList);
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return _int;
    }

    public int getUsesTypeRecurse(String _type) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        this.getAllTypeRecurse(_type, inventoryItemList);
        int _int = getUses(inventoryItemList);
        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return _int;
    }

    public int getWeightReduction() {
        return this.weightReduction;
    }

    public void setWeightReduction(int _weightReduction) {
        _weightReduction = Math.min(_weightReduction, 100);
        _weightReduction = Math.max(_weightReduction, 0);
        this.weightReduction = _weightReduction;
    }

    public void removeAllItems() {
        this.drawDirty = true;
        if (this.parent != null) {
            this.dirty = true;
        }

        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            inventoryItem.container = null;
        }

        this.Items.clear();
        if (this.parent instanceof IsoDeadBody) {
            ((IsoDeadBody)this.parent).checkClothing(null);
        }

        if (this.parent instanceof IsoMannequin) {
            ((IsoMannequin)this.parent).checkClothing(null);
        }
    }

    public boolean containsRecursive(InventoryItem item) {
        for (int _int = 0; _int < this.getItems().size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(_int);
            if (inventoryItem == item) {
                return true;
            }

            if (inventoryItem instanceof InventoryContainer && ((InventoryContainer)inventoryItem).getInventory().containsRecursive(item)) {
                return true;
            }
        }

        return false;
    }

    public int getItemCountFromTypeRecurse(String _type) {
        int int0 = 0;

        for (int int1 = 0; int1 < this.getItems().size(); int1++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(int1);
            if (inventoryItem.getFullType().equals(_type)) {
                int0++;
            }

            if (inventoryItem instanceof InventoryContainer) {
                int int2 = ((InventoryContainer)inventoryItem).getInventory().getItemCountFromTypeRecurse(_type);
                int0 += int2;
            }
        }

        return int0;
    }

    public float getCustomTemperature() {
        return this.customTemperature;
    }

    public void setCustomTemperature(float newTemp) {
        this.customTemperature = newTemp;
    }

    public InventoryItem getItemFromType(String _type, IsoGameCharacter chr, boolean notEquipped, boolean ignoreBroken, boolean includeInv) {
        ItemContainer.InventoryItemList inventoryItemList = ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).alloc();
        if (_type.contains(".")) {
            _type = _type.split("\\.")[1];
        }

        for (int int0 = 0; int0 < this.getItems().size(); int0++) {
            InventoryItem inventoryItem0 = (InventoryItem)this.getItems().get(int0);
            if (!inventoryItem0.getFullType().equals(_type) && !inventoryItem0.getType().equals(_type)) {
                if (includeInv
                    && inventoryItem0 instanceof InventoryContainer
                    && ((InventoryContainer)inventoryItem0).getInventory() != null
                    && !inventoryItemList.contains(inventoryItem0)) {
                    inventoryItemList.add(inventoryItem0);
                }
            } else if ((!notEquipped || chr == null || !chr.isEquippedClothing(inventoryItem0)) && this.testBroken(ignoreBroken, inventoryItem0)) {
                ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                return inventoryItem0;
            }
        }

        for (int int1 = 0; int1 < inventoryItemList.size(); int1++) {
            ItemContainer itemContainer = ((InventoryContainer)inventoryItemList.get(int1)).getInventory();
            InventoryItem inventoryItem1 = itemContainer.getItemFromType(_type, chr, notEquipped, ignoreBroken, includeInv);
            if (inventoryItem1 != null) {
                ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
                return inventoryItem1;
            }
        }

        ((ItemContainer.InventoryItemListPool)TL_itemListPool.get()).release(inventoryItemList);
        return null;
    }

    public InventoryItem getItemFromType(String _type, boolean ignoreBroken, boolean includeInv) {
        return this.getItemFromType(_type, null, false, ignoreBroken, includeInv);
    }

    public InventoryItem getItemFromType(String _type) {
        return this.getFirstType(_type);
    }

    public ArrayList<InventoryItem> getItemsFromType(String _type) {
        return this.getAllType(_type);
    }

    public ArrayList<InventoryItem> getItemsFromFullType(String _type) {
        return _type != null && _type.contains(".") ? this.getAllType(_type) : new ArrayList();
    }

    public ArrayList<InventoryItem> getItemsFromFullType(String _type, boolean includeInv) {
        if (_type != null && _type.contains(".")) {
            return includeInv ? this.getAllTypeRecurse(_type) : this.getAllType(_type);
        } else {
            return new ArrayList();
        }
    }

    public ArrayList<InventoryItem> getItemsFromType(String _type, boolean includeInv) {
        return includeInv ? this.getAllTypeRecurse(_type) : this.getAllType(_type);
    }

    public ArrayList<InventoryItem> getItemsFromCategory(String category) {
        return this.getAllCategory(category);
    }

    public void sendContentsToRemoteContainer() {
        if (GameClient.bClient) {
            this.sendContentsToRemoteContainer(GameClient.connection);
        }
    }

    public void requestSync() {
        if (GameClient.bClient) {
            if (this.parent == null || this.parent.square == null || this.parent.square.chunk == null) {
                return;
            }

            GameClient.instance.worldObjectsSyncReq.putRequestSyncIsoChunk(this.parent.square.chunk);
        }
    }

    public void requestServerItemsForContainer() {
        if (this.parent != null && this.parent.square != null) {
            UdpConnection udpConnection = GameClient.connection;
            ByteBufferWriter byteBufferWriter = udpConnection.startPacket();
            PacketTypes.PacketType.RequestItemsForContainer.doPacket(byteBufferWriter);
            byteBufferWriter.putShort(IsoPlayer.getInstance().OnlineID);
            byteBufferWriter.putUTF(this.type);
            if (this.parent.square.getRoom() != null) {
                byteBufferWriter.putUTF(this.parent.square.getRoom().getName());
            } else {
                byteBufferWriter.putUTF("all");
            }

            byteBufferWriter.putInt(this.parent.square.getX());
            byteBufferWriter.putInt(this.parent.square.getY());
            byteBufferWriter.putInt(this.parent.square.getZ());
            int _int = this.parent.square.getObjects().indexOf(this.parent);
            if (_int == -1 && this.parent.square.getStaticMovingObjects().indexOf(this.parent) != -1) {
                byteBufferWriter.putShort((short)0);
                _int = this.parent.square.getStaticMovingObjects().indexOf(this.parent);
                byteBufferWriter.putByte((byte)_int);
            } else if (this.parent instanceof IsoWorldInventoryObject) {
                byteBufferWriter.putShort((short)1);
                byteBufferWriter.putInt(((IsoWorldInventoryObject)this.parent).getItem().id);
            } else if (this.parent instanceof BaseVehicle) {
                byteBufferWriter.putShort((short)3);
                byteBufferWriter.putShort(((BaseVehicle)this.parent).VehicleID);
                byteBufferWriter.putByte((byte)this.vehiclePart.getIndex());
            } else {
                byteBufferWriter.putShort((short)2);
                byteBufferWriter.putByte((byte)_int);
                byteBufferWriter.putByte((byte)this.parent.getContainerIndex(this));
            }

            PacketTypes.PacketType.RequestItemsForContainer.send(udpConnection);
        }
    }

    @Deprecated
    public void sendContentsToRemoteContainer(UdpConnection connection) {
        ByteBufferWriter byteBufferWriter = connection.startPacket();
        PacketTypes.PacketType.AddInventoryItemToContainer.doPacket(byteBufferWriter);
        byteBufferWriter.putInt(0);
        boolean _boolean = false;
        byteBufferWriter.putInt(this.parent.square.getX());
        byteBufferWriter.putInt(this.parent.square.getY());
        byteBufferWriter.putInt(this.parent.square.getZ());
        byteBufferWriter.putByte((byte)this.parent.square.getObjects().indexOf(this.parent));

        try {
            CompressIdenticalItems.save(byteBufferWriter.bb, this.Items, null);
        } catch (Exception exception) {
            exception.printStackTrace();
        }

        PacketTypes.PacketType.AddInventoryItemToContainer.send(connection);
    }

    public InventoryItem getItemWithIDRecursiv(int id) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.id == id) {
                return inventoryItem;
            }

            if (inventoryItem instanceof InventoryContainer
                && ((InventoryContainer)inventoryItem).getItemContainer() != null
                && !((InventoryContainer)inventoryItem).getItemContainer().getItems().isEmpty()) {
                inventoryItem = ((InventoryContainer)inventoryItem).getItemContainer().getItemWithIDRecursiv(id);
                if (inventoryItem != null) {
                    return inventoryItem;
                }
            }
        }

        return null;
    }

    public InventoryItem getItemWithID(int id) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.id == id) {
                return inventoryItem;
            }
        }

        return null;
    }

    public boolean removeItemWithID(int id) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.id == id) {
                this.Remove(inventoryItem);
                return true;
            }
        }

        return false;
    }

    public boolean containsID(int id) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.id == id) {
                return true;
            }
        }

        return false;
    }

    public boolean removeItemWithIDRecurse(int id) {
        for (int _int = 0; _int < this.Items.size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.Items.get(_int);
            if (inventoryItem.id == id) {
                this.Remove(inventoryItem);
                return true;
            }

            if (inventoryItem instanceof InventoryContainer && ((InventoryContainer)inventoryItem).getInventory().removeItemWithIDRecurse(id)) {
                return true;
            }
        }

        return false;
    }

    public boolean isHasBeenLooted() {
        return this.hasBeenLooted;
    }

    public void setHasBeenLooted(boolean _hasBeenLooted) {
        this.hasBeenLooted = _hasBeenLooted;
    }

    public String getOpenSound() {
        return this.openSound;
    }

    public void setOpenSound(String _openSound) {
        this.openSound = _openSound;
    }

    public String getCloseSound() {
        return this.closeSound;
    }

    public void setCloseSound(String _closeSound) {
        this.closeSound = _closeSound;
    }

    public String getPutSound() {
        return this.putSound;
    }

    public void setPutSound(String _putSound) {
        this.putSound = _putSound;
    }

    public InventoryItem haveThisKeyId(int keyId) {
        for (int _int = 0; _int < this.getItems().size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(_int);
            if (inventoryItem instanceof Key key) {
                if (key.getKeyId() == keyId) {
                    return key;
                }
            } else if (inventoryItem.getType().equals("KeyRing") && ((InventoryContainer)inventoryItem).getInventory().haveThisKeyId(keyId) != null) {
                return ((InventoryContainer)inventoryItem).getInventory().haveThisKeyId(keyId);
            }
        }

        return null;
    }

    public String getOnlyAcceptCategory() {
        return this.OnlyAcceptCategory;
    }

    public void setOnlyAcceptCategory(String onlyAcceptCategory) {
        this.OnlyAcceptCategory = StringUtils.discardNullOrWhitespace(onlyAcceptCategory);
    }

    public String getAcceptItemFunction() {
        return this.AcceptItemFunction;
    }

    public void setAcceptItemFunction(String functionName) {
        this.AcceptItemFunction = StringUtils.discardNullOrWhitespace(functionName);
    }

    public IsoGameCharacter getCharacter() {
        if (this.getParent() instanceof IsoGameCharacter) {
            return (IsoGameCharacter)this.getParent();
        } else {
            return this.containingItem != null && this.containingItem.getContainer() != null ? this.containingItem.getContainer().getCharacter() : null;
        }
    }

    public void emptyIt() {
        this.Items = new ArrayList();
    }

    public LinkedHashMap<String, InventoryItem> getItems4Admin() {
        LinkedHashMap linkedHashMap = new LinkedHashMap();

        for (int _int = 0; _int < this.getItems().size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(_int);
            inventoryItem.setCount(1);
            if (inventoryItem.getCat() != ItemType.Drainable
                && inventoryItem.getCat() != ItemType.Weapon
                && linkedHashMap.get(inventoryItem.getFullType()) != null
                && !(inventoryItem instanceof InventoryContainer)) {
                ((InventoryItem)linkedHashMap.get(inventoryItem.getFullType()))
                    .setCount(((InventoryItem)linkedHashMap.get(inventoryItem.getFullType())).getCount() + 1);
            } else if (linkedHashMap.get(inventoryItem.getFullType()) != null) {
                linkedHashMap.put(inventoryItem.getFullType() + Rand.Next(100000), inventoryItem);
            } else {
                linkedHashMap.put(inventoryItem.getFullType(), inventoryItem);
            }
        }

        return linkedHashMap;
    }

    public LinkedHashMap<String, InventoryItem> getAllItems(LinkedHashMap<String, InventoryItem> items, boolean inInv) {
        if (items == null) {
            items = new LinkedHashMap();
        }

        for (int _int = 0; _int < this.getItems().size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(_int);
            if (inInv) {
                inventoryItem.setWorker("inInv");
            }

            inventoryItem.setCount(1);
            if (inventoryItem.getCat() != ItemType.Drainable && inventoryItem.getCat() != ItemType.Weapon && items.get(inventoryItem.getFullType()) != null) {
                ((InventoryItem)items.get(inventoryItem.getFullType())).setCount(((InventoryItem)items.get(inventoryItem.getFullType())).getCount() + 1);
            } else if (items.get(inventoryItem.getFullType()) != null) {
                items.put(inventoryItem.getFullType() + Rand.Next(100000), inventoryItem);
            } else {
                items.put(inventoryItem.getFullType(), inventoryItem);
            }

            if (inventoryItem instanceof InventoryContainer
                && ((InventoryContainer)inventoryItem).getItemContainer() != null
                && !((InventoryContainer)inventoryItem).getItemContainer().getItems().isEmpty()) {
                items = ((InventoryContainer)inventoryItem).getItemContainer().getAllItems(items, true);
            }
        }

        return items;
    }

    public InventoryItem getItemById(long id) {
        for (int _int = 0; _int < this.getItems().size(); _int++) {
            InventoryItem inventoryItem = (InventoryItem)this.getItems().get(_int);
            if ((long)inventoryItem.getID() == id) {
                return inventoryItem;
            }

            if (inventoryItem instanceof InventoryContainer
                && ((InventoryContainer)inventoryItem).getItemContainer() != null
                && !((InventoryContainer)inventoryItem).getItemContainer().getItems().isEmpty()) {
                inventoryItem = ((InventoryContainer)inventoryItem).getItemContainer().getItemById(id);
                if (inventoryItem != null) {
                    return inventoryItem;
                }
            }
        }

        return null;
    }

    public void addItemsToProcessItems() {
        IsoWorld.instance.CurrentCell.addToProcessItems(this.Items);
    }

    public void removeItemsFromProcessItems() {
        IsoWorld.instance.CurrentCell.addToProcessItemsRemove(this.Items);
        if (!"floor".equals(this.type)) {
            ItemSoundManager.removeItems(this.Items);
        }
    }

    public boolean isExistYet() {
        if (!zombie.SystemDisabler.doWorldSyncEnable) {
            return true;
        } else if (this.getCharacter() != null) {
            return true;
        } else if (this.getParent() instanceof BaseVehicle) {
            return true;
        } else if (this.parent instanceof IsoDeadBody) {
            return this.parent.getStaticMovingObjectIndex() != -1;
        } else if (this.parent instanceof IsoCompost) {
            return this.parent.getObjectIndex() != -1;
        } else if (this.containingItem != null && this.containingItem.worldItem != null) {
            return this.containingItem.worldItem.getWorldObjectIndex() != -1;
        } else if (this.getType().equals("floor")) {
            return true;
        } else if (this.SourceGrid == null) {
            return false;
        } else {
            IsoGridSquare isoGridSquare = this.SourceGrid;
            return !isoGridSquare.getObjects().contains(this.parent) ? false : this.parent.getContainerIndex(this) != -1;
        }
    }

    public String getContainerPosition() {
        return this.containerPosition;
    }

    public void setContainerPosition(String _containerPosition) {
        this.containerPosition = _containerPosition;
    }

    public String getFreezerPosition() {
        return this.freezerPosition;
    }

    public void setFreezerPosition(String _freezerPosition) {
        this.freezerPosition = _freezerPosition;
    }

    public VehiclePart getVehiclePart() {
        return this.vehiclePart;
    }

    private static final class CategoryPredicate implements Predicate<InventoryItem> {
        String category;

        ItemContainer.CategoryPredicate init(String string) {
            this.category = (String)Objects.requireNonNull(string);
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return inventoryItem.getCategory().equals(this.category);
        }
    }

    private static final class Comparators {
        ObjectPool<ItemContainer.ConditionComparator> condition = new ObjectPool<>(ItemContainer.ConditionComparator::new);
        ObjectPool<ItemContainer.EvalComparator> eval = new ObjectPool<>(ItemContainer.EvalComparator::new);
        ObjectPool<ItemContainer.EvalArgComparator> evalArg = new ObjectPool<>(ItemContainer.EvalArgComparator::new);
    }

    private static final class ConditionComparator implements Comparator<InventoryItem> {
        public int compare(InventoryItem inventoryItem1, InventoryItem inventoryItem0) {
            return inventoryItem1.getCondition() - inventoryItem0.getCondition();
        }
    }

    private static final class EvalArgComparator implements Comparator<InventoryItem> {
        LuaClosure functionObj;
        Object arg;

        ItemContainer.EvalArgComparator init(LuaClosure luaClosure, Object object) {
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            this.arg = object;
            return this;
        }

        public int compare(InventoryItem inventoryItem0, InventoryItem inventoryItem1) {
            LuaReturn luaReturn = LuaManager.caller.protectedCall(LuaManager.thread, this.functionObj, new Object[]{inventoryItem0, inventoryItem1, this.arg});
            if (luaReturn.isSuccess() && !luaReturn.isEmpty() && luaReturn.getFirst() instanceof Double) {
                double _double = (Double)luaReturn.getFirst();
                return Double.compare(_double, 0.0);
            } else {
                return 0;
            }
        }
    }

    private static final class EvalArgPredicate implements Predicate<InventoryItem> {
        LuaClosure functionObj;
        Object arg;

        ItemContainer.EvalArgPredicate init(LuaClosure luaClosure, Object object) {
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            this.arg = object;
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return LuaManager.caller.protectedCallBoolean(LuaManager.thread, this.functionObj, inventoryItem, this.arg) == Boolean.TRUE;
        }
    }

    private static final class EvalComparator implements Comparator<InventoryItem> {
        LuaClosure functionObj;

        ItemContainer.EvalComparator init(LuaClosure luaClosure) {
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            return this;
        }

        public int compare(InventoryItem inventoryItem0, InventoryItem inventoryItem1) {
            LuaReturn luaReturn = LuaManager.caller.protectedCall(LuaManager.thread, this.functionObj, new Object[]{inventoryItem0, inventoryItem1});
            if (luaReturn.isSuccess() && !luaReturn.isEmpty() && luaReturn.getFirst() instanceof Double) {
                double _double = (Double)luaReturn.getFirst();
                return Double.compare(_double, 0.0);
            } else {
                return 0;
            }
        }
    }

    private static final class EvalPredicate implements Predicate<InventoryItem> {
        LuaClosure functionObj;

        ItemContainer.EvalPredicate init(LuaClosure luaClosure) {
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return LuaManager.caller.protectedCallBoolean(LuaManager.thread, this.functionObj, inventoryItem) == Boolean.TRUE;
        }
    }

    private static final class InventoryItemList extends ArrayList<InventoryItem> {
        public boolean equals(Object object) {
            return this == object;
        }
    }

    private static final class InventoryItemListPool extends ObjectPool<ItemContainer.InventoryItemList> {
        public InventoryItemListPool() {
            super(ItemContainer.InventoryItemList::new);
        }

        public void release(ItemContainer.InventoryItemList inventoryItemList) {
            inventoryItemList.clear();
            super.release(inventoryItemList);
        }
    }

    private static final class Predicates {
        final ObjectPool<ItemContainer.CategoryPredicate> category = new ObjectPool<>(ItemContainer.CategoryPredicate::new);
        final ObjectPool<ItemContainer.EvalPredicate> eval = new ObjectPool<>(ItemContainer.EvalPredicate::new);
        final ObjectPool<ItemContainer.EvalArgPredicate> evalArg = new ObjectPool<>(ItemContainer.EvalArgPredicate::new);
        final ObjectPool<ItemContainer.TagPredicate> tag = new ObjectPool<>(ItemContainer.TagPredicate::new);
        final ObjectPool<ItemContainer.TagEvalPredicate> tagEval = new ObjectPool<>(ItemContainer.TagEvalPredicate::new);
        final ObjectPool<ItemContainer.TagEvalArgPredicate> tagEvalArg = new ObjectPool<>(ItemContainer.TagEvalArgPredicate::new);
        final ObjectPool<ItemContainer.TypePredicate> type = new ObjectPool<>(ItemContainer.TypePredicate::new);
        final ObjectPool<ItemContainer.TypeEvalPredicate> typeEval = new ObjectPool<>(ItemContainer.TypeEvalPredicate::new);
        final ObjectPool<ItemContainer.TypeEvalArgPredicate> typeEvalArg = new ObjectPool<>(ItemContainer.TypeEvalArgPredicate::new);
    }

    private static final class TagEvalArgPredicate implements Predicate<InventoryItem> {
        String tag;
        LuaClosure functionObj;
        Object arg;

        ItemContainer.TagEvalArgPredicate init(String string, LuaClosure luaClosure, Object object) {
            this.tag = string;
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            this.arg = object;
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return inventoryItem.hasTag(this.tag)
                && LuaManager.caller.protectedCallBoolean(LuaManager.thread, this.functionObj, inventoryItem, this.arg) == Boolean.TRUE;
        }
    }

    private static final class TagEvalPredicate implements Predicate<InventoryItem> {
        String tag;
        LuaClosure functionObj;

        ItemContainer.TagEvalPredicate init(String string, LuaClosure luaClosure) {
            this.tag = string;
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return inventoryItem.hasTag(this.tag) && LuaManager.caller.protectedCallBoolean(LuaManager.thread, this.functionObj, inventoryItem) == Boolean.TRUE;
        }
    }

    private static final class TagPredicate implements Predicate<InventoryItem> {
        String tag;

        ItemContainer.TagPredicate init(String string) {
            this.tag = (String)Objects.requireNonNull(string);
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return inventoryItem.hasTag(this.tag);
        }
    }

    private static final class TypeEvalArgPredicate implements Predicate<InventoryItem> {
        String type;
        LuaClosure functionObj;
        Object arg;

        ItemContainer.TypeEvalArgPredicate init(String string, LuaClosure luaClosure, Object object) {
            this.type = string;
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            this.arg = object;
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return ItemContainer.compareType(this.type, inventoryItem)
                && LuaManager.caller.protectedCallBoolean(LuaManager.thread, this.functionObj, inventoryItem, this.arg) == Boolean.TRUE;
        }
    }

    private static final class TypeEvalPredicate implements Predicate<InventoryItem> {
        String type;
        LuaClosure functionObj;

        ItemContainer.TypeEvalPredicate init(String string, LuaClosure luaClosure) {
            this.type = string;
            this.functionObj = (LuaClosure)Objects.requireNonNull(luaClosure);
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return ItemContainer.compareType(this.type, inventoryItem)
                && LuaManager.caller.protectedCallBoolean(LuaManager.thread, this.functionObj, inventoryItem) == Boolean.TRUE;
        }
    }

    private static final class TypePredicate implements Predicate<InventoryItem> {
        String type;

        ItemContainer.TypePredicate init(String string) {
            this.type = (String)Objects.requireNonNull(string);
            return this;
        }

        public boolean test(InventoryItem inventoryItem) {
            return ItemContainer.compareType(this.type, inventoryItem);
        }
    }
}
